home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-06-30 | 4.7 KB | 154 lines |
- /*
- * @(#)MetalInternalFrameUI.java 1.10 98/02/13
- *
- * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
- *
- * This software is the confidential and proprietary information of Sun
- * Microsystems, Inc. ("Confidential Information"). You shall not
- * disclose such Confidential Information and shall use it only in
- * accordance with the terms of the license agreement you entered into
- * with Sun.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
- * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
- * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
- * THIS SOFTWARE OR ITS DERIVATIVES.
- *
- */
-
- package com.sun.java.swing.plaf.metal;
-
- import java.awt.*;
- import java.awt.event.*;
- import com.sun.java.swing.*;
- import com.sun.java.swing.border.*;
- import com.sun.java.swing.plaf.basic.*;
- import java.util.EventListener;
- import java.beans.PropertyChangeListener;
- import java.beans.PropertyChangeEvent;
- import java.beans.PropertyVetoException;
- import com.sun.java.swing.plaf.*;
- import java.io.Serializable;
-
- /**
- * Metal implementation of JInternalFrame.
- * <p>
- * Warning: serialized objects of this class will not be compatible with
- * future swing releases. The current serialization support is appropriate
- * for short term storage or RMI between Swing1.0 applications. It will
- * not be possible to load serialized Swing1.0 objects with future releases
- * of Swing. The JDK1.2 release of Swing will be the compatibility
- * baseline for the serialized form of Swing objects.
- *
- * @version 1.10 02/13/98
- * @author Steve Wilson
- */
- public class MetalInternalFrameUI extends BasicInternalFrameUI {
-
- private MetalInternalFrameTitlePane titlePane;
-
- private PropertyChangeListener paletteListener;
- private PropertyChangeListener contentPaneListener;
-
- private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0);
-
- protected static String IS_PALETTE = "JInternalFrame.isPalette";
-
- public MetalInternalFrameUI(JInternalFrame b) {
- super(b);
- }
-
- public static ComponentUI createUI(JComponent c) {
- return new MetalInternalFrameUI( (JInternalFrame) c);
- }
-
- public void installUI(JComponent c) {
- frame = (JInternalFrame)c;
-
- paletteListener = new PaletteListener();
- contentPaneListener = new ContentPaneListener();
- c.addPropertyChangeListener(paletteListener);
- c.addPropertyChangeListener(contentPaneListener);
-
- super.installUI(c);
-
- Object paletteProp = c.getClientProperty( IS_PALETTE );
- if ( paletteProp != null ) {
- setPalette( ((Boolean)paletteProp).booleanValue() );
- }
-
- Container content = frame.getContentPane();
- stripContentBorder(content);
- c.setOpaque(false);
- }
-
-
- public void uninstallUI(JComponent c) {
- c.removePropertyChangeListener(paletteListener);
- c.removePropertyChangeListener(contentPaneListener);
-
- Container cont = ((JInternalFrame)(c)).getContentPane();
- if (cont instanceof JComponent) {
- JComponent content = (JComponent)cont;
- if ( content.getBorder() == handyEmptyBorder) {
- content.setBorder(null);
- }
- }
- super.uninstallUI(c);
- }
-
- private void stripContentBorder(Object c) {
- if ( c instanceof JComponent ) {
- JComponent contentComp = (JComponent)c;
- Border contentBorder = contentComp.getBorder();
- if (contentBorder == null || contentBorder instanceof UIResource) {
- contentComp.setBorder( handyEmptyBorder );
- }
- }
- }
-
-
- protected JComponent createNorthPane(JInternalFrame w) {
- titlePane = new MetalInternalFrameTitlePane(w);
- return titlePane;
- }
-
- public void setPalette(boolean isPalette) {
- if (isPalette) {
- LookAndFeel.installBorder(frame, "InternalFrame.paletteBorder");
- } else {
- LookAndFeel.installBorder(frame, "InternalFrame.border");
- }
- titlePane.setPalette(isPalette);
-
- }
-
- class PaletteListener implements PropertyChangeListener, Serializable {
- public void propertyChange(PropertyChangeEvent e) {
- String name = e.getPropertyName();
- if ( name.equals( IS_PALETTE ) ) {
- if ( e.getNewValue() != null ) {
- setPalette( ((Boolean)e.getNewValue()).booleanValue() );
- }
- else {
- setPalette( false );
- }
- }
- }
- } // end class PaletteListener
-
- class ContentPaneListener implements PropertyChangeListener, Serializable {
- public void propertyChange(PropertyChangeEvent e) {
- String name = e.getPropertyName();
- if ( name.equals( JInternalFrame.CONTENT_PANE_PROPERTY ) ) {
- stripContentBorder(e.getNewValue());
- }
- }
- } // end class ContentPaneListener
-
-
- }
-
-